package com.fdb.efp.loan.service.impl;

import java.util.List;

import com.fdb.efp.loan.service.domain.SettleDetailAccountTemp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.fdb.efp.loan.service.dao.SettleDetailAccountTempDao;
import com.fdb.efp.loan.service.facade.SettleDetailAccountTempService;
import com.fdb.efp.loan.service.vo.SettleDetailAccountTempVO;

/**
 * 
 * @date:2018年12月26日 下午2:50:35
 * @author:cenyj
 */
@Service("settleDetailAccountTempService")
public class SettleDetailAccountTempServiceImpl implements SettleDetailAccountTempService, FrameworkService {
	private static Logger logger = LoggerFactory.getLogger(BatCircleaccServiceImpl.class);

	@Autowired
	private SettleDetailAccountTempDao settleDetailAccountTempDao;

	@Override
	public int insert(SettleDetailAccountTempVO record) {
		SettleDetailAccountTemp SettleDetailAccountTempVO = new SettleDetailAccountTemp();
		logger.debug("当前新增数据为:" + SettleDetailAccountTempVO.toString());
		int num = 0;
		try {
			SettleDetailAccountTemp batCircleacc = new SettleDetailAccountTemp();
			beanCopy(SettleDetailAccountTempVO, record);
			num = settleDetailAccountTempDao.insert(batCircleacc);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:" + num);
		return num;
	}

	@Override
	public int insertSelective(SettleDetailAccountTempVO record) {
		SettleDetailAccountTemp SettleDetailAccountTempVO = new SettleDetailAccountTemp();
		logger.debug("当前新增数据为:" + SettleDetailAccountTempVO.toString());
		int num = 0;
		try {
			SettleDetailAccountTemp batCircleacc = new SettleDetailAccountTemp();
			beanCopy(SettleDetailAccountTempVO, record);
			num = settleDetailAccountTempDao.insertSelective(batCircleacc);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:" + num);
		return num;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<SettleDetailAccountTempVO> getSettleDetailAccountTempList() {
		List<SettleDetailAccountTempVO> list = null;
		try {
			List<SettleDetailAccountTemp> listSettleDetailAccountTemps = settleDetailAccountTempDao.getSettleDetailAccountTempList();
			list = (List<SettleDetailAccountTempVO>) beansCopy(listSettleDetailAccountTemps, SettleDetailAccountTempVO.class);
			logger.info("查询数据成功！结果为：" + list);
		} catch (Exception e) {
			e.printStackTrace();
			logger.debug("查询异常！" + e.getMessage());
		}
		return list;
	}
}
